package labs.laba_03;

import java.math.BigDecimal;

public class Dot{
	private float x;
	private float y;
	public Dot(){
		this(0, 0);
	}
	public Dot(float x, float y){
		this.setXY(x, y);
	}
	public void setX(float x){
		this.x = x;
	}
	public void setY(float y){
		this.y = y;
	}
	public void setXY(float x, float y){
		this.x = BigDecimal.valueOf(x).setScale(3).floatValue();
		this.y = BigDecimal.valueOf(y).setScale(3).floatValue();
	}
	public float getX() {
		return x;
	}
	public float getY() {
		return y;
	}
	public float getXp2() {
		return x*x;
	}
	public float getYp2() {
		return y*y;
	}
	@Override
	public boolean equals(Object o) {
		Dot d = (Dot)o;
		if(d.x==this.x && d.y==this.y) return true;
		return false;
	}
	public float getDistanceTo(Dot d){
		return (float)Math.sqrt(Math.pow((this.x-d.x), 2) + Math.pow((this.y-d.y), 2));
	}
	public boolean isOrigin(){
		return (this.x==0 && this.y==0);
	}
}
